package com.twu.biblioteca.ui.menus.books;

import com.twu.biblioteca.items.Book;
import com.twu.biblioteca.library.Library;
import com.twu.biblioteca.ui.menus.AbstractMenu;

import java.util.Collection;

/**
 * @author Alvi Jonathan Sait
 */
public class ReturnBookMenu extends ListBooksMenu {

    public ReturnBookMenu(Library library) {
        super(library);
    }

    @Override
    public AbstractMenu handleInput(String input) {
        Book book = getUser().getBooks().get(input);
        if (book != null) {
            book.acceptReturner(getUser());
            return new SuccessfulBookReturnMenu(getLibrary());
        }
        return new UnsuccessfulBookReturnMenu(getLibrary());
    }

    @Override
    public String getUserPrompt() {
        return "Enter the ISBN of the book you would like to return:";
    }

    @Override
    protected void addMenuItems() {
        // No Menu Items needed in here since user must input the ISBN
    }

    @Override
    protected Collection<Book> getBooks() {
        return getUser().getBooks().values();
    }
}
